package com.mm.util.result;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * 描述: 基础对象
 * 添加JsonIgnore注解，返回时被忽略
 *
 * @author: yanglin
 * @Date: 2021-08-04-11:29
 * @Version: 1.0
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "基础对象", description = "基础对象")
public class DBaseEntity implements Serializable {

    @ApiModelProperty(value = "删除标记（0-未删除；1-已删除）")
    @TableField("del_flg")
    @JsonIgnore
    @TableLogic
    public Integer delFlg;

    @ApiModelProperty(value = "创建人")
    @TableField("create_by")
    @JsonIgnore
    public String createBy;

    @ApiModelProperty(value = "创建时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss",
            timezone = "GMT+8"
    )
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    public Date createTime;

    @ApiModelProperty(value = "更新人")
    @TableField("last_update_by")
    @JsonIgnore
    public String lastUpdateBy;

    @ApiModelProperty(value = "最后更新时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    //@JsonFormat(
    //        pattern = "yyyy-MM-dd HH:mm:ss",
    //        timezone = "GMT+8"
    //)
    @TableField(value = "last_update_time", fill = FieldFill.INSERT_UPDATE)
    @JsonIgnore
    public Date lastUpdateTime;
}
